package com.jial08.designpatterns.strategy.impl;

import com.jial08.designpatterns.strategy.Cash;

/**
 * <p>类描述：满减。</p>
 *
 * @author jl
 * @version v1.0.0.1。
 * @since JDK1.8。
 * <p>创建日期：2019/10/15 上午11:49。</p>
 */
public class CashReturn implements Cash {
	private double moneyCondition;
	private double moneyReturn;

	public CashReturn(double moneyCondition, double moneyReturn) {
		this.moneyCondition = moneyCondition;
		this.moneyReturn = moneyReturn;
	}

	@Override
	public double acceptCash(double money) {
		int num = Double.valueOf(money / moneyCondition).intValue();
		return money - moneyReturn * num;
	}
}
